package com.threeti.jiayusms.domain.service.communicationlog;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.legacy.CommunicationLog;
import com.threeti.jiayusms.framework.util.DynaSearchCriteria;
import com.threeti.jiayusms.framework.util.PagedListHandler;
import com.threeti.jiayusms.infrastructure.communicationlog.CommunicationLogDao;

@Service
@Transactional(readOnly=true)
public class CommunicationLogQueryServiceImpl implements
		CommunicationLogQueryService {

	@Autowired
	private CommunicationLogDao dao;

	@Override
	public CommunicationLog findCommunicationLogBy(Long logId) {
		return dao.loadBy(logId);
	}
	
	@Override
	public CommunicationLog findCommunicationLogBy(String logNo) {
		return dao.loadBy(logNo);
	}
	
	@Override
	public PagedListHandler<CommunicationLog> findAllLogTemplatesByPage(int currentPageIndex, int startingIndex) {
    return dao.findAllLogTemplatesByPage(currentPageIndex, startingIndex);
	}
	
	@Override
	public PagedListHandler<CommunicationLog> findLogTemplatesByPage(DynaSearchCriteria dynaSearchCriteria, int currentPageIndex, int startingIndex) {
		if (!dynaSearchCriteria.isAnyConditionInput()) {//无条件查询
			return dao.findAllLogTemplatesByPage(currentPageIndex, startingIndex);
		}
		return dao.findLogTemplatesByPage(dynaSearchCriteria, currentPageIndex, startingIndex);
	}
	
	public List<CommunicationLog> findLogTemplatesByList(DynaSearchCriteria dynaSearchCriteria){
		return dao.findLogTemplatesByList(dynaSearchCriteria);
	} 
}
